# RT-Thread building script for component

from building import *

cwd     = GetCurrentDir()
src     = []
path    = [cwd]
path   += [cwd + '/config']

if GetDepend('RT_USING_PIN'):
    src += ['drv_gpio.c']
	
if GetDepend('RT_USING_SERIAL'):
    src += ['drv_usart.c']
    
if GetDepend('RT_USING_ADC'):
    src += ['drv_adc.c']

if GetDepend('RT_USING_DAC'):
    src += ['drv_dac.c']    
    
if GetDepend(['BSP_USING_ETH', 'RT_USING_LWIP']):
    src += ['drv_eth.c']
    
if GetDepend('BSP_USING_I2C'):
    src += ['drv_soft_i2c.c']          

if GetDepend('BSP_USING_SPI'):
    src += ['drv_spi.c'] 

if GetDepend(['BSP_USING_SPI_FLASH']):
    src += ['spi_flash_init.c']
    
if GetDepend('RT_USING_WDT'):
    src += ['drv_wdt.c']

if GetDepend('RT_USING_PWM'):
    src += ['drv_pwm.c']
    
if GetDepend('RT_USING_SDIO'):
    src += ['drv_sdio.c']

if GetDepend('BSP_USING_SRAM'):
    src += ['drv_sram.c']	

if GetDepend('BSP_USING_AUDIO'):    
    src += Glob('drv_es8388.c')
    src += Glob('drv_sound.c')  
     	    
if GetDepend('BSP_USING_ES8388'):    
    src += Glob('drv_es8388.c')

if GetDepend('BSP_USING_LCD'):
    src += ['drv_lcd.c']	


group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path)

objs = [group]

list = os.listdir(cwd)

for item in list:
    if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
        objs = objs + SConscript(os.path.join(item, 'SConscript'))

Return('objs')
